﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
                    xmlns:Tfsvm="clr-namespace:VisualWip.TFS2010Providers;assembly=TFS2010Providers"
                    >

    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeFlatList"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerflatlist.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeOneHop"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerdirectlink.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeTree"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorertree.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_FolderExpanded"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerfolderexpanded.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_FolderCollapsed"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerfoldercollapsed.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_MyQueries"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorermyqueries.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_TeamQueries"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerteamqueries.png" />

    <Tfsvm:QueryItemToImageSourceConverter x:Key="imageConverter" />

    <Style x:Key="ColumnTypeStyle" TargetType="{x:Type FrameworkElement}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                <Setter Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing done column">
                <Setter Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="QuerysStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <HierarchicalDataTemplate x:Key="QuerysItemsTemplate" ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image >
                <Image.Source>
                    <MultiBinding Converter="{StaticResource imageConverter}">
                        <Binding Path="."/>
                        <Binding Path="IsExpanded"/>
                    </MultiBinding>
                </Image.Source>
            </Image>
            <TextBlock Text="{Binding Name}" />
        </StackPanel>
    </HierarchicalDataTemplate>


    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkSingleQuerySettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkSingleQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoingDoneSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkInProgressGroupSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoingSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoneSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate x:Key="TfsWorkSingleQuerySettingsView">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="2" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Label Content="Work in progress limit" />
            <TextBox Grid.Column="2" Text="{Binding TotalWorkInProgressLimit, Mode=TwoWay}" />
            <Label Grid.Row="1" Content="Work item size" />
            <ComboBox Grid.Row="1" Grid.Column="2" Height="23" Name="workItemSizeComboBox" ItemsSource="{Binding Sizes}" DisplayMemberPath="Name" SelectedItem="{Binding Size,Mode=TwoWay}" />
            <Label Grid.Row="2" Content="Column type" />
            <ComboBox Grid.Row="2" Grid.Column="2" Height="23" Name="columnTypeComboBox" ItemsSource="{Binding ColumnTypes}" DisplayMemberPath="Name" SelectedItem="{Binding ColumnType,Mode=TwoWay}" />
            <StackPanel Grid.Row="3"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding AvailableChecked, Mode=TwoWay}" />
                <Label Content="Avalible slots" />
            </StackPanel>
            <StackPanel Grid.Row="4"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding DownloadDisplayFieldsOnly, Mode=TwoWay}" />
                <Label Content="Only show the field that are defiend in the query" />
            </StackPanel>
            <TextBlock Grid.Row="5"  Grid.Column="2" TextWrapping="Wrap">Select this option if you only want the fields defiened as columns in the team query to be shown. This will improve performance.</TextBlock>

            <Label Grid.Row="6" Grid.ColumnSpan="3" Content="Select query that will populate this column" />
            <TreeView Grid.Row="7" Grid.ColumnSpan="3" ItemsSource="{Binding Querys.Children}" ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="TfsWorkDualQuerySettingsView">
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="2" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Label Content="Work in progress limit" />
            <TextBox Text="{Binding TotalWorkInProgressLimit, Mode=TwoWay}" Grid.Column="2" />
            <Label Grid.Row="1" Content="Work item size" />
            <ComboBox Grid.Row="1" Grid.Column="2" Height="23" ItemsSource="{Binding Sizes}" DisplayMemberPath="Name" SelectedItem="{Binding Size,Mode=TwoWay}" />
            <Label Grid.Row="2" Content="Column type" Style="{StaticResource ResourceKey=ColumnTypeStyle}" />
            <ComboBox Grid.Row="2" Grid.Column="2" Height="23" ItemsSource="{Binding ColumnTypes}" DisplayMemberPath="Name" SelectedItem="{Binding ColumnType,Mode=TwoWay}" Style="{StaticResource ResourceKey=ColumnTypeStyle}"/>
            <StackPanel Grid.Row="3"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding DownloadDisplayFieldsOnly, Mode=TwoWay}" />
                <Label Content="Only show the field that are defiend in the query" /><Expander />
            </StackPanel>
            <TextBlock Grid.Row="4"  Grid.Column="2" TextWrapping="Wrap">Select this option if you only want the fields defiened as columns in the team query to be shown. This will improve performance.</TextBlock>
            <Label Grid.Row="5" Grid.ColumnSpan="3" Content="Select first query">
                <Label.Style>
                    <Style TargetType="{x:Type Label}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                                <Setter Property="Content" Value="Select first query"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing column">
                                <Setter Property="Content" Value="Select first query. This query will populate the column with work items"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Done column">
                                <Setter Property="Content" Value="Select first query. This query will be used to for calculations"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
            <TreeView  ItemsSource="{Binding FirstQueries.Children}" Grid.Row="6" Grid.ColumnSpan="3"  ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
          <Label Grid.Row="7" Grid.ColumnSpan="3" Content="Select second query">
                <Label.Style>
                    <Style TargetType="{x:Type Label}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                                <Setter Property="Content" Value="Select second query"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing column">
                                <Setter Property="Content" Value="Select second query. This query will be used to for calculations"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Done column">
                                <Setter Property="Content" Value="Select second query. This query will populate the column with work items"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
            <TreeView  ItemsSource="{Binding SecondQueries.Children}" Grid.Row="8" Grid.ColumnSpan="3"  ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
        </Grid>
    </DataTemplate>
    
    <ribbon:RibbonGroup  x:Key="Tfs2010WorkItemWorkProvider" Header="{Binding HeaderName}">
        <ribbon:RibbonButton 
			LargeImageSource="{StaticResource ResourceKey=Column_Single}"
			Label="Add Single column"
            Command="{Binding AddSingleColumnCommand}"
            ToolTipTitle="Add Single column"
            ToolTipDescription="Adds a single Team Query work item column. Use existing or create your own Team Queries in Team Foundation Server to populate the columns."
            ToolTipFooterTitle="Usage"
            ToolTipFooterDescription="A single columns can for example be used to show all user stories that are in the development state. A work-in-progress limit can be added."/>
        <ribbon:RibbonSplitButton
            Label = "Add Doing/Done group"
            Command = "{Binding AddDoingDoneGroupCommand}"
            LargeImageSource ="{StaticResource ResourceKey=Column_WorkInProgressGroup}"
            ToolTipTitle="Add Doing/Done group"
            ToolTipDescription="Adds three dual Team Query columns. All columns use the same Team Queries. Use existing or create your own Team Queries in Team Foundation Server to populate the columns."
            ToolTipFooterTitle="Usage"
            ToolTipFooterDescription="A Doing/Done group can for example be used to show all user stories that are in development doing and developmen done state. A shared work-in-progress limit can be added."
        >
            <ribbon:RibbonGallery
                 ToolTipTitle="Add Work-in-progress, Doing or Done column"
                 ToolTipDescription="Add any of the Work-in-progress, Doing or Done dual Team Query columns. Click for more options.">
                <ribbon:RibbonButton
					LargeImageSource="{StaticResource ResourceKey=Column_WorkInProgressGroup}"
					Label="Add Work-in-progress group column"
                    Command="{Binding AddWorkInProgressGroupCommand}"
                    ToolTipTitle="Add Work-in-progress group column"
                    ToolTipDescription="Adds a dual Team Query work-in-progress group column. Two Team Queries are used to calculate and show the total work-in-progress. Use existing or create your own Team Queries in Team Foundation Server to populate the columns."
                    ToolTipFooterTitle="Usage"
                    ToolTipFooterDescription="A Work-in-progress group column can for example be used to show the total number of user stories that are in development doing and developmen done state. A work-in-progress limit can be added."/>

                <ribbon:RibbonButton 
					LargeImageSource="{StaticResource ResourceKey=Column_Doing}"
					Label="Add Doing column"
                    Command="{Binding AddDoingColumnCommand}"
                    ToolTipTitle="Add Doing column"
                    ToolTipDescription="Adds a dual Team Query doing column. Two Team Queries are used to show the work items from the first Team Query. Use existing or create your own Team Queries in Team Foundation Server to populate the columns."
                    ToolTipFooterTitle="Usage"
                    ToolTipFooterDescription="A doing column can for example be used to show the user stories that are in development doing state. A shared work-in-progress limit between the two Team Queries can be added."
        />
                <ribbon:RibbonButton 
					LargeImageSource="{StaticResource ResourceKey=Column_Done}"
					Label="Add Done column"
                    Command="{Binding AddDoneColumnCommand}"
                    ToolTipTitle="Add Done column"
                    ToolTipDescription="Adds a dual Team Query done column. Two Team Queries are used to show the work items from the second Team Query. Use existing or create your own Team Queries in Team Foundation Server to populate the columns."
                    ToolTipFooterTitle="Usage"
                    ToolTipFooterDescription="A done column can for example be used to show the user stories that are in development done state. A shared work-in-progress limit between the two Team Queries can be added." />
            </ribbon:RibbonGallery>
        </ribbon:RibbonSplitButton>
        <ribbon:RibbonButton 
			LargeImageSource="{StaticResource ResourceKey=Column_WorkItem}"
			Label="Add Single work item column"
            Command="{Binding AddSingleWorkItemColumnCommand}"
            ToolTipTitle="Add Single work item column"
            ToolTipDescription="Adds a single work item column. The work item id is used to get the work item"
            ToolTipFooterTitle="Usage"
            ToolTipFooterDescription="A Single work item column can for example be used to show user stories as a user story map."/>

    </ribbon:RibbonGroup>

</ResourceDictionary>